import torch

# Create a tensor
tensor_01 = torch.arange(12)
print(tensor_01)
# View the size of the tensor
print(tensor_01.shape)
print(tensor_01.numel())
# reshape the size of the tensor
tensor_02 = tensor_01.reshape((3, 4))
print(tensor_02)
# create a tensor full of 0 elements
tensor_03 = torch.zeros(2, 3, 4)
print(tensor_03)
# create a tensor full of 1 elements
tensor_04 = torch.ones(2, 2, 3)
print(tensor_04)
# convert list to a tensor
tensor_05 = torch.tensor([[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]])
print(tensor_05)
print(tensor_05.shape)
# element-wise operation
tensor_05 = torch.tensor([1.0, 2, 3, 4])
tensor_06 = torch.tensor([4, 3, 2, 1])
print(tensor_05 + tensor_06)
print(tensor_06 - tensor_05)
print(tensor_05 / tensor_06)
print(tensor_05 * tensor_06)
print(tensor_05 ** tensor_06)
print(torch.exp(tensor_06))
tensor_07 = torch.arange(12, dtype=torch.float32).reshape((3, 4))
print(tensor_07)
tensor_08 = torch.tensor([[7.0, 4, 1, 2], [1, 2, 3, 4], [4, 5, 6, 7]])
print(torch.cat((tensor_08, tensor_07), dim=0))
print(torch.cat((tensor_08, tensor_07), dim=1))
print(tensor_07 == tensor_08)
print(tensor_08.sum())
print(tensor_08[-1])
print(tensor_08[1:, 2])
tensor_08[1:,0:4] = 123
print(tensor_08)
